package com.hpq.chat.service.srategy.mark;

import com.hpq.common.exception.HttpStatusEnum;
import com.hpq.common.utils.AssertUtil;

import java.util.HashMap;
import java.util.Map;

/**
 *  消息标记策略工厂
 */
public class MsgMarkFactory {
    private static final Map<Integer,AbstractMsgMarkStrategy> STRATEGY_MAP = new HashMap<>();
    public static void register(Integer markType, AbstractMsgMarkStrategy strategy) {
        STRATEGY_MAP.put(markType, strategy);
    }

    public static AbstractMsgMarkStrategy getStrategyNoNull(Integer markType) {
        AbstractMsgMarkStrategy strategy = STRATEGY_MAP.get(markType);
        AssertUtil.isEmpty(strategy, HttpStatusEnum.PARAM_VALID);
        return strategy;
    }

}
